import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

export class UserModel {
  async createUser(name: string, email: string) {
    return prisma.user.create({
      data: { name, email },
    });
  }

  async getUsers() {
    return prisma.user.findMany();
  }

  async getUserById(id: string) {
    return prisma.user.findUnique({
      where: { id },
    });
  }

  async updateUser(id: string, name?: string, email?: string) {
    return prisma.user.update({
      where: { id },
      data: { name, email },
    });
  }

  async deleteUser(id: string) {
    return prisma.user.delete({
      where: { id },
    });
  }
}